import tornado.ioloop
import tornado.options
import tornado.httpserver
import tornado.web
import os

from tornado.options import define, options

from handler import *
from menu import create_my_menu
from wechat import wechat
from msg import send_msg

define("port", default=80, help="run on the given port", type=int)


def start():
    print('server started')
    tornado.options.parse_command_line()
    app = tornado.web.Application(
        handlers=[
            (r"/", ValidateHandler),
            (r"/join", RegisterHandler),
            (r"/admin", AdminHandler),
            (r"/auth", WebAuthHandler),
        ],
        template_path=os.path.join(os.path.dirname(__file__), "view")
    )
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(80)
    tornado.ioloop.IOLoop.instance().start()


def setup_wechat():
    # create_my_menu()
    wechat.set_template_industry(1, 1)

if __name__ == '__main__':
    send_msg()
    start()
